using OpenBlock.Core;
using OpenBlock.Core.Event;
using OpenBlock.Core.Event.HUDRequest;
using OpenBlock.GUI.Panels;
using OpenBlock.Terrain;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace OpenBlock.GUI
{
    [RequireComponent(typeof(RectTransform))]
    public class HUD : MonoBehaviour
    {
        [Tooltip("Runtime")]
        [SerializeField]
        private WorldObj world;
        [SerializeField]
        private PanelManager panelManager;

        [Tooltip("Resources")]
        [SerializeField]
        private BasePanel colorPalettePanelPrefab;

        private void OnEnable()
        {
            GameManager.Instance.eventQueue.RegisterHandler(GameEventType.HUDRequest, HandleEvents);
        }

        private void OnDisable()
        {
            
        }

        private void HandleEvents(IGameEvent e)
        {
            if (e is OpenColorPaletteEvent p)
            {
                panelManager.OpenPanel(colorPalettePanelPrefab, PanelManager.OpenMode.Replace, p.brushState);
            }
        }
    }
}